home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Views / Pane Frames / Frame.cp next >
Text File  |  2000-06-23  |  2KB  |  96 lines

  1. // Frame.cp
  2.  
  3. #ifndef Frame_h
  4. #include "Frame.h"
  5. #endif
  6. #ifndef MinMax_h
  7. #include "MinMax.h"
  8. #endif
  9. #ifndef Overflow_h
  10. #include "Overflow.h"
  11. #endif
  12.  
  13. void Frame::Arrange( UPoint32 size )
  14.   {
  15.     Rectangle32 inside;
  16.         inside.left = Min( -thickness.left, Asint32(size.h) );
  17.         inside.top  = Min( -thickness.top,  Asint32(size.v) );
  18.         inside.right =  Max( Asint32(size.h) - thickness.right,  inside.left );
  19.         inside.bottom = Max( Asint32(size.v) - thickness.bottom, inside.top  );
  20.     
  21.     Rectangle32 outside( 0, 0, Asint32(size.h), Asint32(size.v) );
  22.     
  23.     interior.SetBounds( inside );
  24.     exterior.SetBounds( outside );
  25.   }
  26.  
  27. int32 Frame::OuterWidth( int32 inner ) const
  28.   {
  29.     return ( inner < maxint32 - thickness.Width() )
  30.                 ? inner + thickness.Width()
  31.                 : maxint32;
  32.   }
  33.  
  34. int32 Frame:: OuterHeight( int32 inner ) const
  35.   {
  36.     return ( inner < maxint32 - thickness.Height() )
  37.                 ? inner + thickness.Height()
  38.                 : maxint32;
  39.   }
  40.  
  41. int32 Frame::MinimumWidth() const
  42.   {
  43.     return OuterWidth( interior.Sizer().MinimumWidth() );
  44.   }
  45.  
  46. int32 Frame:: MinimumHeight() const
  47.   {
  48.     return OuterHeight( interior.Sizer().MinimumHeight() );
  49.   }
  50.  
  51. int32 Frame:: MaximumWidth() const
  52.   {
  53.     return OuterWidth( interior.Sizer().MaximumWidth() );
  54.   }
  55.  
  56. int32 Frame:: MaximumHeight() const
  57.   {
  58.     return OuterHeight( interior.Sizer().MaximumHeight() );
  59.   }
  60.  
  61. int32 Frame:: ReasonableWidth() const
  62.   {
  63.     return OuterWidth( interior.Sizer().ReasonableWidth() );
  64.   }
  65.  
  66. int32 Frame:: ReasonableHeight() const
  67.   {
  68.     return OuterHeight( interior.Sizer().ReasonableHeight() );
  69.   }
  70.  
  71. int32 Frame::BestWidth( Range32 bounds ) const
  72.   {
  73.     int32 frameSize = thickness.Width();
  74.     
  75.     if ( bounds.End() < frameSize )
  76.         return bounds.End();
  77.     
  78.     Range32 innerBounds( bounds.Start() - Min( bounds.Start(), frameSize ),
  79.                                 bounds.End() - frameSize );
  80.     
  81.     return OuterWidth( interior.Sizer().BestWidth( innerBounds ) );
  82.   }
  83.  
  84. int32 Frame::BestHeight( Range32 bounds ) const
  85.   {
  86.     int32 frameSize = thickness.Height();
  87.     
  88.     if ( bounds.End() < frameSize )
  89.         return bounds.End();
  90.     
  91.     Range32 innerBounds( bounds.Start() - Min( bounds.Start(), frameSize ),
  92.                                 bounds.End() - frameSize );
  93.     
  94.     return OuterHeight( interior.Sizer().BestHeight( innerBounds ) );
  95.   }
  96.